<?php
/**
 * @Name: UserTokenServices.php
 * @Author: yashuai<1762910894@qq.com>
 */

namespace app\common\services\rbac;

use HugCode\PhpUnits\InstanceTool;
use HugCode\PhpUnits\Frame\Cipher\TokenJwt;

class UserTokenServices extends TokenJwt
{

    use InstanceTool;

    public function getNodeList(int $userId)
    {
        /** @var NodeServices $nodeService */
        $nodeService = app()->make(NodeServices::class);
        $userNodeId  = $nodeService->getUserNodeIDArray($userId);
        return $nodeService->column(['NodeID', 'in', $userNodeId], 'EventType');
    }

    public function nodeRelationPower()
    {
        $power = [
            'index.*'                 => 'allow',  // 首页数据
            'users.menu-node'         => 'allow',  // 用户菜单
            'users.info'              => 'allow',  // 用户详情
            'users.reset-my-password' => 'allow',  // 重置自己的密码
            'role.node'               => ['node.index'], // 菜单接点
            'role.select'             => ['users.*'], // 角色下拉框
        ];
        $info  = [  // 有index权限就有info权限
            // 'material',
        ];
        return [$power, $info];
    }


}
